<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>
    <style>
        td {
            border: 1px solid black;
        }
    </style>
</head>
<!--该案例有删除提交功能
1.bug1:html表格边框默认不显示，设置边框即可，由于属性参数写错，style的boder属性被划掉了，还有黄色的三角形
收获：style的boder属性被划掉，还有黄色的三角形一种情况是因为参数写错
-->

<body>
    <div id="a">
        <div>
            id:<input type="text" v-model='id'> name :
            <input type="text" v-model='name'> <input type="button" value="提交" @click='tijiao'>搜索名称关键字：<input type="text">
        </div>
        <table id='a'>
            <thead>
                <tr>
                    <td>id</td>
                    <td>name</td>
                    <td>ctime</td>
                    <td>operation</td>
                </tr>
            </thead>
            <tbody>
                <tr v-for='(it,index) in shuju'>
                    <td>{{it.id}}</td>
                    <td>{{it.name}}</td>
                    <td>{{it.ctime}}</td>
                    <td @click='shanchu(index)'>删除</td>
                </tr>
            </tbody>
            <tfoot></tfoot>
        </table>
    </div>
    <script>
        new Vue({
            el: '#a',
            data: {
                id: '',
                name: '',
                shuju: [{
                    name: 'a',
                    id: 1,
                    ctime: 12

                }, {
                    name: 'b',
                    id: 2,
                    ctime: 12
                }, {
                    name: 'c',
                    id: 3,
                    ctime: 12
                }, {
                    name: 'd',
                    id: 4,
                    ctime: 12
                }, {
                    name: 'e',
                    id: 5,
                    ctime: 12
                }],
            },
            methods: {
                tijiao: function() {
                    this.shuju.push({
                        name: this.name,
                        id: this.id
                    });
                },
                shanchu: function(index) {

                    this.shuju.splice(index, 1);
                }
            }
        })
    </script>
</body>

</html>